package com.wimcorp.magic.board;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.wimcorp.magic.cards.PlayingCard;
import com.wimcorp.magic.players.Player;

public abstract class Cards extends CardAccessor{

	private Player player;
	private Map<Long, PlayingCard> cards = new HashMap<Long, PlayingCard>();

	public Cards(Player player){
		this.player=player;
	}
	
	public void add(PlayingCard card) {
		cards.put(card.getIdentifier(), card);
		messagePlayersCardAdded(card);
	}

	public void remove(PlayingCard card){
		cards.remove(card.getIdentifier());
	}

	/*public void viewAll() {
		for (PlayingCard card : cards.values()) {
			System.out.println(card.toString());
		}

	}*/

	public void viewCard(int identifier) {
		System.out.println(cards.get(identifier).toString());
	}

	public Collection<PlayingCard> getCards() {
		return cards.values();
	}

	public PlayingCard getCard(long identifier) {
		return cards.get(identifier);
	}
	
	public int size(){
		return cards.size();
	}
	
	protected abstract void messagePlayersCardAdded(PlayingCard card);
	
	public String toString(){
		StringBuilder sb = new StringBuilder();
		for(PlayingCard card : cards.values()){
			sb.append(card.toString());
		}
		return sb.toString();
	}

	public Player getPlayer() {
		return player;
	}

	public void setCards(Map<Long, PlayingCard> cards) {
		this.cards = cards;
	}
	
	
	
	

}
